﻿using System.Management.Automation;
using DotNet.DevOps.Tasks.Network;

namespace DotNet.DevOps.Cmdlets
{
    [Cmdlet(VerbsCommon.Get, "Hostname", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = false, SupportsTransactions = false)]
    public class Get_Hostname : Cmdlet
    {
        [Parameter(Mandatory = false, Position = 0)]
        public string Machine { get; set; }

        private Hostname task;

        protected override void BeginProcessing()
        {
            task = new Hostname(new PowershellCmdletLogger(this))
            {
                Machine = Machine,
                Name = ""
            };
        }

        protected override void ProcessRecord()
        {
            task.Execute();
        }

        protected override void EndProcessing()
        {
            WriteObject(task.Name);
        }
    }
}
